package swing_java;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Jframe {
	public static void main(String[] args) {
		Frame frame = new Frame("Test Button");
		Button button = new Button("Press me");
		
		button.addActionListener(new ButtonHandler());
		frame.add(button, BorderLayout.CENTER);
		frame.pack();
		frame.setVisible(true);
	}
}

class ButtonHandler implements ActionListener {
	@Override
	public void actionPerformed(ActionEvent e) {
		System.out.println("button is pressed!");
		String label  = e.getActionCommand();
		System.out.println(label);
		
	}
	
}